//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include "CathCLF.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <stdexcept>
#include <iostream>
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#define LENGTHTEXT 1000
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
CathCLF::CathCLF (): classN(0),
                     architectureN(0),
                     topologyN(0),
                     homologousSuperFamilyN(0),
                     s35ClusterN(0),
                     s60ClusterN(0),
                     s95ClusterN(0),
                     s100ClusterN(0),
                     s100CountN(0),
                     domainLength(0),
                     structureResolution(0) {
  
  this->domain   = new String ();
  this->toString = new String (); 
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
CathCLF::CathCLF (const CathCLF& cathCLF): classN(cathCLF.classN),
                     architectureN(cathCLF.architectureN),
                     topologyN(cathCLF.topologyN),
                     homologousSuperFamilyN(cathCLF.homologousSuperFamilyN),
                     s35ClusterN(cathCLF.s35ClusterN),
                     s60ClusterN(cathCLF.s60ClusterN),
                     s95ClusterN(cathCLF.s95ClusterN),
                     s100ClusterN(cathCLF.s100ClusterN),
                     s100CountN(cathCLF.s100CountN),
                     domainLength(cathCLF.domainLength),
                     structureResolution(cathCLF.structureResolution) {
  
  this->domain   = new String (cathCLF.domain);
  this->toString = new String (cathCLF.toString);
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
CathCLF::CathCLF (const CathCLF* cathCLF): classN(cathCLF->classN),
                     architectureN(cathCLF->architectureN),
                     topologyN(cathCLF->topologyN),
                     homologousSuperFamilyN(cathCLF->homologousSuperFamilyN),
                     s35ClusterN(cathCLF->s35ClusterN),
                     s60ClusterN(cathCLF->s60ClusterN),
                     s95ClusterN(cathCLF->s95ClusterN),
                     s100ClusterN(cathCLF->s100ClusterN),
                     s100CountN(cathCLF->s100CountN),
                     domainLength(cathCLF->domainLength),
                     structureResolution(cathCLF->structureResolution) {
  
  this->domain   = new String (cathCLF->domain);
  this->toString = new String (cathCLF->toString);
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
CathCLF::~CathCLF () {
  
  if (this->domain)   delete this->domain;
  if (this->toString) delete this->toString;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void CathCLF::Domain (String* domain){
  
  if (domain) this->domain->In(domain);
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void CathCLF::ClassN (int classN){
  
  this->classN = classN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void CathCLF::ArchitectureN (int architectureN){
  
  this->architectureN = architectureN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void CathCLF::TopologyN (int topologyN){
  
  this->topologyN = topologyN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void CathCLF::HomologousSuperFamilyN (int homologousSuperFamilyN){
  
  this->homologousSuperFamilyN = homologousSuperFamilyN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void CathCLF::S35ClusterN (int s35ClusterN){
  
  this->s35ClusterN = s35ClusterN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void CathCLF::S60ClusterN (int s60ClusterN){
  
  this->s60ClusterN = s60ClusterN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void CathCLF::S95ClusterN (int s95ClusterN){
  
  this->s95ClusterN = s95ClusterN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void CathCLF::S100ClusterN (int s100ClusterN){
  
  this->s100ClusterN = s100ClusterN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void CathCLF::S100CountN (int s100CountN){
  
  this->s100CountN = s100CountN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void CathCLF::DomainLength (int domainLength){
  
  this->domainLength = domainLength;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void CathCLF::StructureResolution (double structureResolution) {
  
  this->structureResolution = structureResolution;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* CathCLF::Domain (void){
 
  return this->domain;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int CathCLF::ClassN (void){
  
  return this->classN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int CathCLF::ArchitectureN (void){
  
  return this->architectureN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int CathCLF::TopologyN (void){
  
  return this->topologyN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int CathCLF::HomologousSuperFamilyN (void){
  
  return this->homologousSuperFamilyN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int CathCLF::S35ClusterN (void){
  
  return this->s35ClusterN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int CathCLF::S60ClusterN (void){
  
  return this->s60ClusterN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int CathCLF::S95ClusterN (void){
  
  return this->s95ClusterN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int CathCLF::S100ClusterN (void){
  
  return this->s100ClusterN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int CathCLF::S100CountN (void){
  
  return this->s100CountN;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int CathCLF::DomainLength (void){
  
  return this->domainLength;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
double CathCLF::StructureResolution (void) {
  
  return this->structureResolution;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
bool CathCLF::ReadData (String* data) {
  
  if (!data || !data->Length()) return false;
  
  char  tmpData [data->Length() + 1]; 
  char* parts = NULL;
  
  strcpy(tmpData, data->Out());
  
  if ((parts = strtok(tmpData, " \t\r\n"))) this->domain->In(parts);
  else                                      return false;
  
  if ((parts = strtok(NULL, " \t\r\n")))    this->classN                 = atoi(parts);
  else                                      return false;                         
  
  if ((parts = strtok(NULL, " \t\r\n")))    this->architectureN          = atoi(parts);
  else                                      return false;
  
  if ((parts = strtok(NULL, " \t\r\n")))    this->topologyN              = atoi(parts);
  else                                      return false;
  
  if ((parts = strtok(NULL, " \t\r\n")))    this->homologousSuperFamilyN = atoi(parts);
  else                                      return false;
  
  if ((parts = strtok(NULL, " \t\r\n")))    this->s35ClusterN            = atoi(parts);
  else                                      return false;
  
  if ((parts = strtok(NULL, " \t\r\n")))    this->s60ClusterN            = atoi(parts);
  else                                      return false;
  
  if ((parts = strtok(NULL, " \t\r\n")))    this->s95ClusterN            = atoi(parts);
  else                                      return false;
  
  if ((parts = strtok(NULL, " \t\r\n")))    this->s100ClusterN           = atoi(parts);
  else                                      return false;
  
  if ((parts = strtok(NULL, " \t\r\n")))    this->s100CountN             = atoi(parts);
  else                                      return false;
  
  if ((parts = strtok(NULL, " \t\r\n")))    this->domainLength           = atoi(parts);
  else                                      return false;
  
  if ((parts = strtok(NULL, " \t\r\n")))    this->structureResolution    = atof(parts);
  else                                      return false;
  
  return true;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
bool  CathCLF::ReadData (char* data) {
  
  if (!data) return false;
  
  String dataChar;
  dataChar.In(data);
  
  return this->ReadData(&dataChar);    
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* CathCLF::ToStringCode (void) {
  
  this->toString->In("");
  
  char buffer [LENGTHTEXT + 1];
  
  //                 C  A  T  H  S  O  L  I  D
  sprintf (buffer, "%d.%d.%d.%d.%d.%d.%d.%d.%d\0", this->classN, this->architectureN, this->topologyN, this->homologousSuperFamilyN, this->s35ClusterN, 
                                                   this->s60ClusterN, this->s95ClusterN, this->s100ClusterN, this->s100CountN);
  
  this->toString->In(buffer);
  
  return this->toString;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
CathCLF CathCLF::operator= (const CathCLF& cathCLF) {
  
  this->domain->In(cathCLF.domain);

  this->classN                  = cathCLF.classN;
  this->architectureN           = cathCLF.architectureN;
  this->topologyN               = cathCLF.topologyN;
  this->homologousSuperFamilyN  = cathCLF.homologousSuperFamilyN;
  this->s35ClusterN             = cathCLF.s35ClusterN;
  this->s60ClusterN             = cathCLF.s60ClusterN;
  this->s95ClusterN             = cathCLF.s95ClusterN;
  this->s100ClusterN            = cathCLF.s100ClusterN;
  this->s100CountN              = cathCLF.s100CountN;

  this->domainLength            = cathCLF.domainLength;
  this->structureResolution     = cathCLF.structureResolution;
  
  return *this;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

